class User:
    def __init__(self, user_id=None, username=None, password=None, role=None, name=None, phone=None, address=None):
        self.user_id = user_id
        self.username = username
        self.password = password
        self.role = role  # 'student' 或 'delivery_person'
        self.name = name
        self.phone = phone
        self.address = address
    
    def to_dict(self):
        return {
            'user_id': self.user_id,
            'username': self.username,
            'password': self.password,
            'role': self.role,
            'name': self.name,
            'phone': self.phone,
            'address': self.address
        }
    
    @classmethod
    def from_dict(cls, data):
        return cls(
            user_id=data.get('user_id'),
            username=data.get('username'),
            password=data.get('password'),
            role=data.get('role'),
            name=data.get('name'),
            phone=data.get('phone'),
            address=data.get('address')
        )